
#ifndef _TTG_PIPELINE_PIPELINELOGGER_
#define _TTG_PIPELINE_PIPELINELOGGER_
#include "Common/Definitions.h"

#include "Common/Extras.h"
#include "Runtime.Low/Services.h"
#include "Informations/PipelineInfo.h"

namespace ttg
{
	namespace pipeline
	{
#ifdef TTG_PL_VISUALIZER
		//Contains information about current pipeline state and (optionally) saves it.
		class PipelineLogger :public services::Subscriber
		{
			private:
				ttg_internal::pipeline::PipelineInfo *info;
				bool isSubscribed_OnExit;
				bool isSubscribed_Update;
				extras::TTGXMLTree *xml;
			public:
				//Creates subscriber for "PIPELINE_UPDATE" event.
				//If filename is specified, uses this file as log.
				PipelineLogger(const char *filename = NULL);
				//Tries to subscribe to PIPELINE_UPDATE.
				bool subsrcibe();
				//Stores gathered information to file and stops listening pipeline events.
				void close();
				//Returns current info about pipeline.
				inline ttg_internal::pipeline::PipelineInfo *getInfo()
						{ return info; }
				//Calls PipelineLogger::close().
				~PipelineLogger()
						{ this->close(); }
				static void processPipelineUpdate(services::Subscriber *s, services::Event *ev);
				static void processOnExit(services::Subscriber *s, ttg::services::Event *ev);
		};
#endif
	}
}

#endif
